package com.haoshuang.zhouzhoubang.ui.page.mine.integral

import android.content.Context
import android.os.Bundle
import com.haoshuang.zhouzhoubang.config.URLConstants
import com.haoshuang.zhouzhoubang.databinding.ActivityStoreIntegralBinding
import com.haoshuang.zhouzhoubang.ui.dialog.ConfirmDialog
import com.haoshuang.zhouzhoubang.ui.page.help.detail.HelpDetailActivity
import com.haoshuang.zhouzhoubang.ui.page.mine.integral.detail.StoreIntegralDetailActivity
import com.lnkj.jialubao.utils.AccountUtils
import com.lxj.xpopup.XPopup
import com.mufeng.libs.base.BaseVMActivity
import com.mufeng.libs.utils.ktx.convertFloat
import com.mufeng.libs.utils.startPage
import com.mufeng.libs.utils.toast
import com.mufeng.libs.utils.view.click
import com.mufeng.libs.utils.view.clickWithTrigger


/**
 *  门店积分
 */
class StoreIntegralActivity :
    BaseVMActivity<StoreIntegralViewModel, ActivityStoreIntegralBinding>() {

    companion object {
        fun launch(context: Context) {
            context.startPage<StoreIntegralActivity>()
        }
    }

    override fun initView(savedInstanceState: Bundle?) {

        binding.titleBar.title = "门店经营分"
        binding.titleBar.leftImageView().click { finish() }

        binding. tvGz.clickWithTrigger {
            val url="${URLConstants.baseUrl}/index/index/agreement?id=30"
            startPage<HelpDetailActivity>("title" to "积分规则","url" to url)
        }

        binding.cevScoreDetails.clickWithTrigger {
            startPage<StoreIntegralDetailActivity>()
        }



        binding.llPendingConfirmationTimeoutRate.clickWithTrigger {
            XPopup.Builder(mActivity)
                .asCustom(
                    ConfirmDialog(
                        context =mActivity,
                        title = "待确认超时率",
                        content = "指的是接单或指派后的订单，以接单指派时间为准30分钟内未联系客户确认；",
                        cancelStr = "",
                        confirmStr = "我知道了",
                        isHideCancel = true,
                        onCancel = {},
                        onConfirm = {})
                )
                .show()
        }

        binding.llLateArrivalRateUponArrival.clickWithTrigger {
            XPopup.Builder(mActivity)
                .asCustom(
                    ConfirmDialog(
                        context =mActivity,
                        title = "温馨提示",
//                        content = "指的是接单后需再平台设定规定时间内，进行门店队员的订单分配。",
                        content = "此功能暂未开发",
                        cancelStr = "",
                        confirmStr = "我知道了",
                        isHideCancel = true,
                        onCancel = {},
                        onConfirm = {})
                )
                .show()
        }

        binding.llRefundRate.clickWithTrigger {
            XPopup.Builder(mActivity)
                .asCustom(
                    ConfirmDialog(
                        context =mActivity,
                        title = "退款率",
                        content = "指的是订单中，发生退款订单数占比情况",
                        cancelStr = "",
                        confirmStr = "我知道了",
                        isHideCancel = true,
                        onCancel = {},
                        onConfirm = {})
                )
                .show()
        }

    }

    override fun initData() {

        val user = AccountUtils.user
        binding.tvDesc.text=user?.team?.team_integral_level
        binding.tvIntegral.text=user?.team_integral.toString()
        binding.dialProgress.setValue(user?.team_integral.convertFloat())

        binding.tvPendingConfirmationTimeoutRate.text = user?.team?.overdue_confirm_rate
//        binding.tvLateArrivalRateUponArrival.text = user?.team?.assign_rate
        binding.tvLateArrivalRateUponArrival.text = "0%"
        binding.tvRefundRate.text = user?.team?.refund_rate

    }

    override fun startObserve() {

    }

}